package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
@Api(value = "素材管理", tags = "素材管理")
public class WmMaterialController {

    @Autowired
    WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(@RequestBody MultipartFile multipartFile) {
        return this.wmMaterialService.uploadPicture(multipartFile);
    }


    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto) {
        return this.wmMaterialService.findList(dto);
    }


    @GetMapping("del_picture/{id}")
    public ResponseResult deletePicture(@PathVariable("id") Integer id) {
        return this.wmMaterialService.deletePicture(id);
    }

    @GetMapping("collect/{id}")
    public ResponseResult collectionMaterial(@PathVariable("id") Integer id) {
        return this.wmMaterialService.collectionMaterial(id);
    }

    @GetMapping("cancel_collect/{id}")
    public ResponseResult cancelCollectionMaterial(@PathVariable("id") Integer id) {
        return this.wmMaterialService.cancelCollectionMaterial(id);
    }
}
